/**
    GpsNetwork lets you download files and log some system parameters from NetRs DGPS receivers.

    Copyright (C) 2009  Eduardo Maureira

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    email:emaureir@gmail.com
 */
package gui;

import java.awt.Color;

/**
 * @author Eduardo
 *
 */
public class ValorColor {

	private String valor;
	private Color statusColor;

	public ValorColor(String valor, Color statusColor) {
		super();
		this.statusColor = statusColor;
		this.valor = valor;
	}

	public String getValor() {
		return valor;
	}

	public void setValor(String valor) {
		this.valor = valor;
	}

	public Color getStatusColor() {
		return statusColor;
	}

	public void setStatusColor(Color statusColor) {
		this.statusColor = statusColor;
	}	


	/**
	 * Convierte un objeto color en un STRING html que representa el color.
	 * @param color
	 * @return representacion HTML del color
	 */
	public static String colorToHTML(Color color)
	{
		StringBuilder respuesta;
		respuesta = new StringBuilder ();
		respuesta.append("#");
		String hexRED,hexGREEN,hexBLUE;

		hexRED = Integer.toHexString( color.getRed());
		hexGREEN = Integer.toHexString( color.getGreen());
		hexBLUE = Integer.toHexString( color.getBlue());
		if (hexRED.length()<2) {
			respuesta.append(0);
		}
		respuesta.append(hexRED);
		if (hexGREEN.length()<2) {
			respuesta.append(0);
		}
		respuesta.append(hexGREEN);
		if (hexBLUE.length()<2) {
			respuesta.append(0);
		}
		respuesta.append(hexBLUE);
		return respuesta.toString();
	}

}
